package com.gary.loader;

/**
 * @author peng_rui
 * @date 2022/2/19
 */
public class LoaderTest {
    public static void main(String[] args) {
        ClassLoader classLoader = ClassLoader.getSystemClassLoader();
        System.out.println(classLoader);//获取系统类加载器 AppClassLoader

        ClassLoader extClassLoader = classLoader.getParent();
        System.out.println(extClassLoader);//获取系统类加载器的上层加载器 ExtClassLoader

        ClassLoader bootStrapClassLoader = extClassLoader.getParent();
        System.out.println(bootStrapClassLoader);//获取扩展类加载器的上层加载器 null  (BootStrapClassLoader 引导类加载器)

        ClassLoader customerLoader = LoaderTest.class.getClassLoader();
        System.out.println(customerLoader);//获取用户自定义类的加载器 AppClassLoader

        ClassLoader coreLoader = Integer.class.getClassLoader();
        System.out.println(coreLoader);//获取Java核心类的类加载器 null

        ClassLoader coreLoader2 = String.class.getClassLoader();
        System.out.println(coreLoader2);//获取Java核心类的类加载器 null
    }
}
